package com.wehealth.adapter;

import java.util.List;

import com.wehealth.R;
import com.wehealth.dm.DM_PlanDay;
import com.wehealth.dm.QuestionData;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Adapter_QuestionList extends BaseAdapter {

	/**
	 * 上下文
	 */
	private Context ctx;
	/**
	 * 列表数据
	 */
	private List<QuestionData> theList;
	
	public Adapter_QuestionList(Context ctx,List<QuestionData> theList){
		this.ctx = ctx;
		this.theList = theList;
	}

	@Override
	public int getCount() {
		return theList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		
		View view = LayoutInflater.from(ctx).inflate(R.layout.question_item,null);
		
		
		TextView depart = (TextView)view.findViewById(R.id.questionkeshi_tv);
		depart.setText(theList.get(arg0).getDepartName());
		
	   TextView dorctor = (TextView)view.findViewById(R.id.question_pay);
	   String payStyle =ctx.getString(R.string.question_pay_free);
	   if(theList.get(arg0).getDrID().equals("0")){
	   dorctor.setText(payStyle);
	   }else{
	       payStyle =ctx.getString(R.string.question_pay);
	       dorctor.setText(payStyle);  
	     }
	   TextView descrption = (TextView)view.findViewById(R.id.question_descrption);
	   descrption.setText(theList.get(arg0).getDesciption());
	   
       TextView time = (TextView)view.findViewById(R.id.question_time);
       time.setText(theList.get(arg0).gettime());
       
       TextView state = (TextView)view.findViewById(R.id.question_state);
       String result =ctx.getString(R.string.question_reply_result_state2);
        if(theList.get(arg0).getisCompleted()==0){
            result =ctx.getString(R.string.question_reply_result_state1);
            }
        state.setText(result);
		return view;
	}

}